﻿//  Key Tracker - An application to keep track of product keys.
//
//  Copyright (c) 2009  Shawn Rakowski
//
//  Permission is hereby granted, free of charge, to any person
//  obtaining a copy of this software and associated documentation
//  files (the "Software"), to deal in the Software without
//  restriction, including without limitation the rights to use,
//  copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the
//  Software is furnished to do so, subject to the following
//  conditions:
//
//  The above copyright notice and this permission notice shall be
//  included in all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
//  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
//  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
//  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
//  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
//  OTHER DEALINGS IN THE SOFTWARE.
// --------------------------------------------------------------------------//
/*      SettingsForm.cs 
 *      
 * 
 *      Key Tracker Project   
 *      
 *      CODE FILE DESCRIPTION:
 *      
 *          This code file contains all the classes and methods for the
 *          settings forms that is run when the settings menu items is 
 *          selected from the file menu on the main form.
 * 
 *      AUTHOR(S):
 *      
 *          Shawn Rakowski
 * 
 *      CLASSES:
 *      
 *          SettingsForm : Form
 *      
 *      MODIFICATION HISTORY:
 *      
 *          06-AUG-2008     Shawn R.    New Program.
 *          10-AUG-2008     Shawn R.    Added use replicated checkbox.
 *          17-MAR-2009     Shawn R.    Changed Font.
 * 
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KeyTracker.Forms
{
    public partial class SettingsForm : Form
    {
        public SettingsForm()
        {
            InitializeComponent();
        }

        private void SettingsForm_Load(object sender, EventArgs e)
        {
            replicatedDBCheckBox.Checked = Properties.Settings.Default.UseRelplicatedDatabase;
            autoHyphenCheckBox.Checked = Properties.Settings.Default.AutoHyphenByDefault;
            rhCheckBox.Checked = Properties.Settings.Default.DeleteHyphenWhenAutoHyphenUnchecked;
            ahSectionNumericUpDown.Value = Properties.Settings.Default.AutoHyphenLength;
            autoConnectCheckBox.Checked = Properties.Settings.Default.EnableDatabaseAutoConnect;
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.UseRelplicatedDatabase != replicatedDBCheckBox.Checked)
            {
                string
                    message = "Enabling or disabling replicated databases will take effect next time you " +
                              "connect or reconnect to a database or restart the program.";
                MessageBox.Show(message, "Key Tracker", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            Properties.Settings.Default.UseRelplicatedDatabase = replicatedDBCheckBox.Checked;
            Properties.Settings.Default.AutoHyphenByDefault = autoHyphenCheckBox.Checked;
            Properties.Settings.Default.DeleteHyphenWhenAutoHyphenUnchecked = rhCheckBox.Checked;
            Properties.Settings.Default.AutoHyphenLength = (int)ahSectionNumericUpDown.Value;
            Properties.Settings.Default.EnableDatabaseAutoConnect = autoConnectCheckBox.Checked;
            Properties.Settings.Default.Save();
            Close();
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
